﻿using System;
using System.Threading;
using System.Windows;
using CommonLibrary;

namespace SmartController.Views
{
    /// <summary>
    /// Description for OutputWindow.
    /// </summary>
    public partial class OutputWindow : Window
    {
        private readonly IAppContext _context;
        private readonly Thread _refreshThread;

        public OutputWindow(IAppContext context)
        {
            InitializeComponent();
            _context = context;

            _refreshThread = new Thread(RefreshThread) { IsBackground = true };
            _refreshThread.Start();
        }

        private void RefreshThread()
        {
            while (true)
            {
                Thread.Sleep(100);

                Dispatcher.BeginInvoke(new Action(delegate()
                                                      {
                                                          DataContext = null;
                                                          DataContext = _context;
                                                      }));
                
            }
        }
    }

}